Doing \copy after a file upload. - Mailing list pgsql-general

From lynch@lscorp.com (Richard Lynch)
Subject Doing \copy after a file upload.
Date
Msg-id v02140b1bb1c29d94eb3f@[207.152.64.133]
Whole thread Raw
List pgsql-general
This is cross-posted to PHP3 and pgsql-general because it's a half/half
sort of thing... Please check replies carefully and avoid too-specific
answers going to both lists.  If in doubt, email me direct, and I'll
summarize where appropriate  THANKS!!!

#1  I'm running PHP3b6 because my ISP can't get RCx/final to compile yet.

#2  I'm not super concerned about security because the only guy who can
access the page to do this upload (validated via DES-encrypted password
thru php<->postgresql) may make stupid mistakes, but is *incapable* of
hacking *anything*.  Trust me on this one. :-)

#3  I've RTFM to the point where I have the files I need uploaded, and
they're in my tmp dir.

#4  I can do '\copy blah from /path/to/tmp' in psql just fine.
#4a I can't do 'copy blah from ...' because of "Postges superuser privilege".
    [Dunno if that's feature of my ISPs setup or beta or what.]

#5  I thought I could do pg_Exec($conn, "\\copy blah from $path"); on the
assumption that that's something I could type in psql, and so is an SQL
statement, so \copy oughta work just like an SQL statement works...
#5a I get:
Warning: PostgresSQL query failed: ERROR: parser: parse error at or near "\" in
/iiw/htdocs/chatmusic.com/upload.php on line 78

#6  Not sure whether:
    A.  I was naive about \copy working like an SQL statement.
    B.  I've done something bone-headed in the pg_Exec
    B1. I know I need \\, since \ sez "bad escape sequence"
    C.  I should research system/shell/passthrough stuff
        Do you get the idea that I'm not even sure which one does what?...
    C1. I would need to do psql -u, but then how do I pass in username/passord?
        [Straight psql won't work from a shell for me, due to ISP setup.]

#7  I hope you understand all this better than I do. :-^

Advice welcome.

PS  In my multiple attempts at this, Netscape 3 on my mac seems really
weird.  When I post the form, I have to hit reload for it to actually post
the upload.  It works on reload only.  Submit does not instantiate the
$filename variables.  Reload does.  Subsequent reloads complain about a
missing nsfile on my local hard drive before it even tries to contact the
server, which I guess was a temporary copy of what I'm trying to upload.
Quite annoying though.  If it's Netscape cacheing I can deal with it, but
if it rings a bell for somebody on some other problem...

--
--
-- "TANSTAAFL" Rich lynch@lscorp.com



pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [GENERAL] Problems with \dt
Next
From: lynch@lscorp.com (Richard Lynch)
Date:
Subject: Vacuum